Skip to content

[fp-enhancer] Improve pkg/actionpins: eliminate mutable shortSHA variable#30808

Merged
pelikhan merged 1 commit intomainfrom
fp-enhancer/actionpins-b75f04ac48f57659
May 7, 2026
Merged

[fp-enhancer] Improve pkg/actionpins: eliminate mutable shortSHA variable#30808
pelikhan merged 1 commit intomainfrom
fp-enhancer/actionpins-b75f04ac48f57659

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 7, 2026

Summary

Applies a tasteful immutability improvement to pkg/actionpins as part of a round-robin functional-programming enhancement pass.

Change

In countPinKeyMismatches, the shortSHA variable was declared mutable and conditionally reassigned:

// Before
shortSHA := pin.SHA
if len(pin.SHA) > 8 {
    shortSHA = pin.SHA[:8]
}

Replaced with a single immutable declaration using Go's built-in min function (available since Go 1.21):

// After
shortSHA := pin.SHA[:min(len(pin.SHA), 8)]

Benefits

  • Immutability: Variable is now initialized once and never reassigned
  • Clarity: Intent is immediately obvious — take at most 8 chars
  • Conciseness: 4 lines → 1 line

Round-Robin Progress

  • Processed: pkg/actionpins (first package in cycle)
  • Next run: pkg/agentdrain

Validation

  • make build passes
  • make fmt passes
  • TestCountPinKeyMismatches_ReturnsOnlyVersionMismatches passes
  • No behaviour changes

References: §25489567849

Generated by Functional Pragmatist · ● 7.7M ·

  • expires on May 8, 2026, 10:17 AM UTC

…ariable

Replace the two-step mutable initialization of shortSHA with a single
immutable declaration using Go's built-in min function.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review May 7, 2026 14:29
Copilot AI review requested due to automatic review settings May 7, 2026 14:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors countPinKeyMismatches in pkg/actionpins to compute a shortened SHA without using a mutable local variable, relying on Go’s built-in min to slice to at most 8 characters.

Changes:

  • Replaces a conditional reassignment of shortSHA with a single immutable slice expression.
  • Keeps the warning log output behavior equivalent while simplifying the code path.
Show a summary per file
File Description
pkg/actionpins/actionpins.go Makes shortSHA initialization immutable by slicing to min(len(pin.SHA), 8) before logging key/version mismatch warnings.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@github-actions github-actions Bot mentioned this pull request May 7, 2026
Copy link
Copy Markdown
Contributor Author

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · ● 1.6M

@pelikhan pelikhan merged commit 5ca657e into main May 7, 2026
48 checks passed
@pelikhan pelikhan deleted the fp-enhancer/actionpins-b75f04ac48f57659 branch May 7, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants